<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="s1_access" :rules="rules" label-width="100px" id="mvcfm">
          <div class="form-unit">
            <span class="mvc-title-left"> 登陆信息 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="登陆账号" prop="username">
                  <el-input v-model="s1_access.username" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="账号邮箱" prop="email">
                  {{s1_access.email}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="2">
                <el-form-item label="邮件通知" prop="is_mail">
                  <el-checkbox-group v-model="s1_access.is_mail" size="medium">
                    <el-checkbox key="true">通知</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <div class='el-form-item__label'>是否将密码发送至邮箱帐号</div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="随机密码" prop="is_rand">
                  <el-checkbox-group v-model="s1_access.username" size="medium">
                    <el-checkbox key="true">随机</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="4">
                <el-form-item label="登陆密码" prop="password">
                  <el-input type="password" v-model="s1_access.password" />
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <div class='el-form-item__label'>非必须,默认为123456</div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="重复密码" prop="password1">
                  <el-input type="password" v-model="s1_access.password1" />
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="staffRegisterInfoUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/oa/humanresources/StaffRegister?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'账户信息'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'StaffRegisterInfoUp',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s1_access: {
          username: null,
          email: null,
          is_mail: [],
          username: [],
          password: null,
          password1: null,
        },
        loading: false,
        Container: null,
        rules: {
          username: [{
            required: true,
            message: "登陆账号不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "507F29B70D824801B06B178B061EF810",
        name: "员工管理右菜单",
        selected: "账户信息"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/humanresources/EmployeeAction/staffRegisterInfoUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      staffRegisterInfoUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/oa/humanresources/EmployeeAction/staffRegisterInfoUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/oa/humanresources/StaffRegister/staffRegister?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
